
#region copyright notice
//Copyright (c) 2005 Dariush Tasdighi (http://www.IranianExperts.com)
//Permission is hereby granted, free of charge, to any person obtaining a copy
//of this software and associated documentation files (the "Software"), to deal
//in the Software without restriction, including without limitation the rights
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//copies of the Software, and to permit persons to whom the Software is
//furnished to do so, subject to the following conditions:
//The above copyright notice and this permission notice shall be included in
//all copies or substantial portions of the Software.
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//THE SOFTWARE.
#endregion


namespace IranianExperts.RSS
{
	public class RSSItemCollection : System.Collections.CollectionBase
	{
		/// <summary>
		/// Indexer.
		/// </summary>
		public RSSItem this[int index]
		{
			get
			{
				return((RSSItem) List[index]);
			}
		}

		/// <summary>
		/// Default Constructor.
		/// </summary>
		public RSSItemCollection()
		{
		}

		/// <summary>
		/// Add new a RSSItem to collection.
		/// </summary>
		/// <param name="item"></param>
		/// <returns></returns>
		public int Add(RSSItem item)
		{
			return(List.Add(item));
		}

		/// <summary>
		/// Add new a RSSItem to collection.
		/// </summary>
		/// <param name="title"></param>
		/// <returns></returns>
		public int Add(string title)
		{
			RSSItem oRSSItem = new RSSItem(title);

			return(Add(oRSSItem));
		}

		/// <summary>
		/// Add new a RSSItem to collection.
		/// </summary>
		/// <param name="title"></param>
		/// <param name="link"></param>
		/// <returns></returns>
		public int Add(string title, string link)
		{
			RSSItem oRSSItem = new RSSItem(title, link);

			return(Add(oRSSItem));
		}

		/// <summary>
		/// Remove a RSSItem from collection.
		/// </summary>
		/// <param name="item"></param>
		public void Remove(RSSItem item)
		{
			List.Remove(item);
		}

		/// <summary>
		/// Find a RSSItem by its Title from collection.
		/// </summary>
		/// <param name="title"></param>
		/// <returns></returns>
		public RSSItem FindByTitle(string title)
		{
			int intIndex = 0;
			int intFoundIndex = -1;

			while((intIndex <= List.Count - 1) && (intFoundIndex == -1))
			{
				if(((RSSItem) List[intIndex]).Title == title)
					intFoundIndex = intIndex;

				intIndex++;
			}

			if(intFoundIndex == -1)
				return(null);
			else
				return(this[intFoundIndex]);
		}

		#region Support
		public static string Owner
		{
			get
			{
				return("Dariush Tasdighi - From Tehran, Iran");
			}
		}

		public static string Version
		{
			get
			{
				return("1.0.0");
			}
		}

		public static string Support
		{
			get
			{
				return("Dariush@IranianExperts.com;DariushT@GMail.com;DariushTasdighi@Yahoo.com");
			}
		}

		public static string Homepage
		{
			get
			{
				return("http://www.IranianExperts.com;http://groups.yahoo.com/group/IranianExperts");
			}
		}

		public static string UpdatedDate
		{
			get
			{
				return("14 Feb 2005");
			}
		}
		#endregion
	}
}
